<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">信用卡广告位管理</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="新增" icon="fa fa-plus" action="#{loanNewAdvertCreditCardListBean.add()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh" update="@form"
                                         actionListener="#{loanNewAdvertCreditCardListBean.onRest()}"/>
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <h1>查询条件</h1>

                            <div class="ui-g-1">
                                <p:outputLabel value="平台"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu  value="#{loanNewAdvertCreditCardListBean.$.platform}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItem itemLabel="通用" itemValue="0" />
                                    <f:selectItem itemLabel="安卓" itemValue="android" />
                                    <f:selectItem itemLabel="ios" itemValue="ios" />
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="产品"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu filter="true" filterMatchMode="startsWith"  value="#{loanNewAdvertCreditCardListBean.$.prdid}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItem itemLabel="通用" itemValue="9999" />
                                    <f:selectItems value="#{loanNewAdvertCreditCardListBean.getCommProductIds()}" var="commProduct"
                                                   itemLabel="#{commProduct.name}" itemValue="#{commProduct.productId}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="标签"/>
                            </div>
                            <div class="ui-g-2">
                                <p:inputText value="#{loanNewAdvertCreditCardListBean.$.tag}"/>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="状态"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu  value="#{loanNewAdvertCreditCardListBean.$.status}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItem itemLabel="上线" itemValue="1" />
                                    <f:selectItem itemLabel="下线" itemValue="0" />
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="广告位"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu  value="#{loanNewAdvertCreditCardListBean.$.advertSpace}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItems  value="#{loanNewAdvertCreditCardListBean.dictionaries[DictionaryCode.NEW_CREDIT_CARD_ADVERT]}"
                                                    var="dic"
                                                   itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>

                        </div>
                        <div class="card ui-g-12">
                            <p:dataTable id="credit-card-list"
                                         style="width: 100%;text-align: center"
                                         var="record"
                                         value="#{loanNewAdvertCreditCardListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="操作">
                                    <p:splitButton icon="fa fa-eye"
                                                   process="@this"
                                                action="#{loanNewAdvertCreditCardListBean.toInfo(record.id)}">
                                        <f:setPropertyActionListener
                                                value="/views/family/credithousekeeper/credit-card-advert-list.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="上线" icon="fa fa-arrow-up"
                                                    action="#{loanNewAdvertCreditCardListBean.onLine(record.id)}"
                                                    process="@this" update="@form"
                                                    rendered="#{!record.showOffButton()}"/>

                                        <p:menuitem value="下线" icon="fa fa-arrow-down"
                                                    action="#{loanNewAdvertCreditCardListBean.offLine(record.id)}"
                                                    process="@this" update="@form"
                                                    rendered="#{record.showOffButton()}"/>
                                    </p:splitButton>
                                </p:column>

                                <p:column headerText="渠道">
                                    <h:outputText value="#{record.channel}"/>
                                </p:column>
                                <p:column headerText="活动id">
                                    <h:outputText value="#{record.cardId}"/>
                                </p:column>

                                <p:column headerText="Logo">
                                    <p:graphicImage
                                            url="#{record.logo}"
                                            width="80px" height="40px"/>
                                </p:column>
                                <p:column headerText="活动名称">
                                    <h:outputText value="#{record.cardName}"/>
                                </p:column>

                                <p:column headerText="广告位">
                                    <h:outputText value="#{loanNewAdvertCreditCardListBean.translate(DictionaryCode.NEW_CREDIT_CARD_ADVERT,record.advertId)}"/>
                                </p:column>

                                <p:column headerText="状态">
                                    <h:outputText value="#{record.status == 1 ? '上线中' : '下线中'}"/>
                                </p:column>

                                <p:column headerText="顺序">
                                    <h:outputText value="#{record.sort}"/>
                                </p:column>

                                <p:column headerText="更新人">
                                    <h:outputText value="#{record.updator}"/>
                                </p:column>
                                <p:column headerText="更新时间">
                                    <h:outputText value="#{record.updateTime}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
